package me.keiwu.pub.data.config;

import lombok.Data;
import me.keiwu.pub.util.BigDecimalUtil;

/**
 * Created by kei on 07/02/2018.
 */
@Data
public class RankRateConfigBean {

    // 参考 configType
    private Integer configType;

    // 日活比例
    private Double activity;

    // 步数比例
    private Double step;

    private Integer maxStep = 1000;

    // 金币比例
    private Double gold;

    // 登记比例
    private Double level;

    // 挑战个数比例
    private Double challengeCnt;

    // 进行中的挑战个数比例
    private Double startingCnt;

    // 胜率比例
    private Double winRate;

    // 探索比例
    private Double explore;


    public double calcResult(int activity, int step, int gold, int level, int challengeCnt, int startingCnt,
                           double winRate, int explore) {
        double result = 1;

        double tmp = BigDecimalUtil.mul(this.activity, activity);
        result = BigDecimalUtil.mul(result, tmp);

        tmp = BigDecimalUtil.mul(this.step, step);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        tmp = BigDecimalUtil.mul(this.gold, gold);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        tmp = BigDecimalUtil.mul(this.level, level);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        int count = challengeCnt - startingCnt;
        tmp = BigDecimalUtil.mul(this.challengeCnt, count);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        tmp = BigDecimalUtil.mul(this.startingCnt, startingCnt);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        tmp = BigDecimalUtil.mul(this.winRate, winRate);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        tmp = BigDecimalUtil.mul(this.explore, explore);
        result = BigDecimalUtil.mul(result, tmp == 0 ? 1 : tmp);

        return result;
    }


    public static void main(String[] args) {
        RankRateConfigBean bean = new RankRateConfigBean();
        bean.activity = 0.08;
        bean.challengeCnt = 0.19;
        bean.explore = 0.22;
        bean.gold = 0.07;
        bean.level = 0.06;
        bean.startingCnt = 0.21;
        bean.maxStep = 1000;
        bean.step = 0.06;
        bean.winRate = 0.11;

        double result = bean.calcResult(0, 1000, 9, 1, 16, 12, 0.5, 25);
        System.out.println(result);
    }


}
